<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            width: 200px;
            border-spacing: 0;
            /* border-collapse: collapse; */
            text-align: center;
        }

        table td {
            border: 1px solid #000;
            padding: 5px;
        }
    </style>
</head>

<body>
    <input type="button" id="btn" value="创建表格">
    <div id="dv"></div>
</body>
<script>
    // let obj = document.getElementById('btn');
    // console.log(obj.getAttributeNames()[0] == 'type');

    let tabObj = {
        百度: 'https://www.baidu.com',
        小米: 'https://www.mi.com/',
        微博: 'https://www.mi.com/',
    }
    let str = '';
    for (let key in tabObj) {
        str += '<tr>'
        str += '<td>' + key + '</td>';
        str += '<td><a href="' + tabObj[key] + '">' + key + '</a></td>';
        str += '</tr>'
    }
    // console.log(str);

    document.getElementById('btn').onclick = function () {
        let listTabObj = document.createElement('table');
        listTabObj.innerHTML = str;
        document.getElementById('dv').appendChild(listTabObj);

    }
</script>

</html>